package com.olive.utils;

import java.security.SecureRandom;

public class AlgorithmUtil {

	//////////////// ASE////////////////////////////

	public static String getAESRandomKey() {
		SecureRandom random = new SecureRandom();
		long randomKey = random.nextLong();
		return String.valueOf(randomKey);
	}

	public static String encryptWithAES(String data, String key) throws Exception {
		return AESUtil.encryptWithBC(data, key);
	}

	public static String decryptWithAES(String data, String key) throws Exception {
		return AESUtil.decryptWithBC(data, key);
	}

	////////////////// RSA////////////////////////////

	public static String encryptWithRSA(String data, String key) throws Exception {
		return RSAUtil.encryptByPublicKey(data, key);
	}

	public static String decryptWithRSA(String data, String key) throws Exception {
		return new String(RSAUtil.decryptByPrivateKey(data, key), "utf-8");
	}

	public static String sign(String data, String key) throws Exception {
		return RSAUtil.sign(data.getBytes(), key);
	}

	public static boolean verify(String data, String key, String signData) throws Exception {
		return RSAUtil.verify(data.getBytes(), key, signData);
	}
}
